import React, { Component} from 'react'
import ReactDOM from 'react-dom'

class XChart{
  constructor(container,data,options){
      container.innerHTML='渲染了一个XCHART'
  }

  update(data,options){

  }

  destroy(){

  }


}

export default class ReactXChart extends Component {
  componentDidMount(){
    const container=ReactDOM.findDOMNode(this);
    const {data,options}=this.props;
    this.chart=new XChart(container,data,options);
  }

  componentDidUpdate(){
    const {data,options}=this.props;
    if(this.chart){
      this.chart.update(data,options);
    }
  }

  componentWillUnmount(){
    if(this.chart){
      this.chart.destroy();
      this.chart=null;
    }
  }

  render() {
    return (
      <div class="x-chart-wrapper">
        xchart
      </div>
    )
  }
}
